<template>
  <swiper class="sw-wrapper" :options="swiperOption" ref="mySwiper" v-if="isSwiperShow">
    <!-- slides -->
    <swiper-slide v-for="item in swiperList" :key="item.id">
      <img class="swiper-img" :src="item.imgUrl" alt="">
    </swiper-slide>
    <!-- Optional controls -->
    <div class="swiper-pagination"  slot="pagination"></div>
  </swiper>
</template>

<script>
  export default {
    name: 'HomeSwiper',
    props: {
      swiperList: Array
    },
    data() {
      return {
        swiperOption: {
          // some swiper options/callbacks
          // 所有的参数同 swiper 官方 api 参数
          pagination: '.swiper-pagination',
          loop: true
        }
      }
    },
    computed: {
      isSwiperShow: function(){
        return this.swiperList.length;
      }
    }
  }
</script>

<style lang="stylus" scoped>
  //样式穿透
  .sw-wrapper >>> .swiper-pagination-bullet-active
    background-color #fff
  .sw-wrapper
    width 100%
    height 3rem
    background-color #eee
  .sw-wrapper .swiper-img
    width 100%
    height 100%
</style>